window.mobileAdapter = () =>{
  let currentState;
  const boardToggleDt = "-75%";
  let wrate=1,hrate=1;
  const boardElement = document.querySelector('.data-board');

    // 适配移动端
  function resize() {
    const wWidth = document.documentElement.clientWidth;
    const wHeight = document.documentElement.clientHeight;
    wrate = wHeight / 860;
    hrate = wWidth / 880;
    if(!boardElement) return;
    boardElement.style.border= 'none';
    boardElement.style.boxShadow= 'none';
    boardElement.style.left= 0;
    boardElement.style.top= 0;
    boardElement.style.paddingTop = "2.5rem";
    boardElement.style.transformOrigin = "top left";
    boardElement.style.overflow = "hidden";
      if (wWidth > wHeight) {
      currentState = "row";
      if(wWidth / wHeight <= 1.5){
        wrate = wWidth / 2 / 860
      }
      boardElement.style.transform = `scale(${wrate})`;
      window.map.setCenter([112, 28])
    } else {
      currentState = "column";
      if (wHeight / wWidth <= 1.5) {
        hrate = wHeight / 2 / 860
      }
      boardElement.style.transform = `scale(${hrate})`;
      window.map.setCenter([112.8, 28.8])
    }
  }
  window.addEventListener('orientationchange', reload);
  window.addEventListener('resize', reload);
  function reload(){
    document.querySelector("#loading-mask").style.display = "block"; // 去除loading
    // resize();
    location.reload()
  }

  function bindDataBoardToggle(){
    const element = document.querySelector(".data-board");
    let dt = 0;
    const toggleBoard = () => {
        dt = dt ? 0 : boardToggleDt;
        element.style.height = dt ? "230px" : "840px";
        // element.style.transform = `scale(${currentState ==='column' ? hrate : wrate}) translateX(${currentState ==='column'? "0" : dt}) translateY(${currentState ==='column'? dt: "0"})`
    };
    element.addEventListener('touchstart',toggleBoard );

  }

  // 重置尺寸
  resize();
  // 绑定面板交互
  bindDataBoardToggle();
  // const expandBtn = document.createElement("div");
  // expandBtn.innerText = ">>";
  // expandBtn.className = "expand-button";
  //   boardElement.appendChild(expandBtn)
}
